package com.escool.controller;

import java.util.Map;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.escool.model.TbResponsable;
import com.escool.service.PagadorService;



@Controller
public class PagadorController {
	
	@Autowired
	PagadorService pagadorService;
	
	@RequestMapping("showPagador")
	public String listNiveles(Map<String, Object> map){
		map.put("tbResponsable", new TbResponsable());
		map.put("pagadorList", pagadorService.listTbResponsable());
		return "/ingresoPagador";
	}
	
	@RequestMapping(value = "addPagador", method = RequestMethod.POST)
	public String addNiveles(@ModelAttribute("tbResponsable") @Valid TbResponsable tbResponsable, BindingResult result){
		if (!result.hasErrors()) {
			//estudiantesService.addAlumnos(tbalumnos);
			pagadorService.addPagador(tbResponsable);
			return "redirect:/showPagador";
		}
		return "";
	}
	
}
